<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * 团购信息从表
 * @ author: zuorenci
 * @ email: 904725327@qq.com
 * @ date: 2017/10/24 21:01
 */
class TuanImg extends Model
{

    protected $table = 'tuan_img';

    public $timestamps = false;

    protected $primaryKey = 'img_id';

    protected $fillable = [
        'img_id', //主键id
        'tuan_id', //团购id
        'img_url', //图片路径
        'intro', //图片介绍
        'img_url_oss',
    ];

    protected $casts = ['img_url'];

    public function getImgUrlAttribute($value)
    {
        return \App\Library\HandleFile::handleFilePath($value,$this->img_url_oss);
    }

    public function tuan()
    {
        return $this->hasOne('App\\Models\\Tuan', 'tuan_id', 'tuan_id');
    }
}
